XMLElement xml;
String[] t_tag;
int[] t_count;
int v_convertit;
Fonte[] t_o_tag;
PFont maFonte;


void setup(){
  size(900, 600);

  maFonte = createFont("data/AGaramondPro-Regular.otf", 50);
  xml = new XMLElement(this, "../tagmehdi.xml"); // appel du fichier XML
  int v_nbrPost = xml.getChildCount();
  t_tag = new String[0];
  t_count = new int[0];

  for (int i = 0; i < v_nbrPost; i++) {
    XMLElement v_post = xml.getChild(i); // Initialise un objet v_post qui correspond au i-eme enfant du noeud XML

    v_convertit =  int(v_post.getStringAttribute("count"));
    
    if(v_convertit > 7){
      t_tag = append(t_tag,v_post.getStringAttribute("tag"));
      t_count = append(t_count,v_convertit);
    }
  }

  t_o_tag = new Fonte[t_tag.length];

  for(int i = 0; i < t_o_tag.length; i++){
    t_o_tag[i] = new Fonte(t_count[i],t_tag[i]);
    t_o_tag[i].ecrit();
  }
  noLoop();
}

void draw(){

  for(int i = 0; i < t_o_tag.length; i++){
    float x = random(300);
    float y = random(400);
 
    //println(x);
    //println(y);
    t_o_tag[i].bouge(x,y);

  }
  

}


